'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model'),
    Routing = require('./Routing.server.model');

var modelField = {};
modelField.Routing = {
    type: Schema.ObjectId,
    ref: 'Routing',
    Name: '工艺路线',
    IsEmpty: false
};
//序号
modelField.Sequence = {
    type: Number,
    Name: '序号',
    IsEmpty: false
};
//工序名称
modelField.Name = {
    type: String,
    default:'',
    trim: true,
    Name: '名称',
    IsEmpty: false
};
//标准作业
modelField.Work = {
    type: Schema.ObjectId,
    ref: 'Work',
    Name: '作业',
    IsEmpty: false
};
//是否计时
modelField.IsTiming = {
    type: Boolean,
    default: false
};
//准备工时
modelField.ReadyWorkHours = {
    type: Number
};
//加工工时
modelField.MachinWorkHours = {
    type: Number
};
//是否质检点
modelField.IsQCpoint = {
    type: Boolean,
    default: false
};
//是否检查点
modelField.IsCheckPoint = {
    type: Boolean,
    default: false
};
//是否入库点
modelField.IsStoragePoint = {
    type: Boolean,
    default: false
};
//是否统计点
modelField.IsCountPoint = {
    type: Boolean,
    default: false
};
modelField.ErpId = {
    type: String,
    trim: true
};
//是否允许多次扫描
modelField.IsMultScan = {
    type: Boolean,
    default: false
};
//允许扫描次数
modelField.ScanCounts = {
    type: Number
};
modelField.IsEffective = {
    type: Boolean
};

var newModel = new Model(modelField);
newModel.addIndex({Routing: 1, Sequence: 1}, {"unique": true});
newModel.addIndex({Routing: 1, Work: 1});
newModel.create('Operation', '工序', null, 'Routing');
